package d;

import java.io.IOException;
import java.net.DatagramSocket;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2024-04-27
 * Time: 22:49
 */
public class UdpDictServer extends UdpEchoServer{
    Map<String ,String> dict = null;

    public UdpDictServer(int port) throws SocketException {
        super(port);
        dict = new HashMap<>();
        dict.put("hello","你好");
        dict.put("cat","猫"+"小猫");
        dict.put("dog","小狗");
        dict.put("fly","飞");

    }

    @Override
    public String process(String resquest) {
        return  dict.getOrDefault(resquest,"该词汇没有查到!");
    }

    public static void main(String[] args) throws IOException {
        UdpDictServer server = new UdpDictServer(9090);
        server.start();
    }
}
